import React from 'react';
import { inject, observer } from 'mobx-react';
import {WeaTableNew} from 'comsMobx';
const WeaTable = WeaTableNew.WeaTable;
import allStores from '../../stores/index'
import { WeaErrorPage, WeaTools } from 'ecCom';
import {Input,Button,Alert,Spin,Icon,Modal,message} from 'antd';
import {routerShape} from 'react-router';

import isEmpty from 'lodash/isEmpty'
/**
 * 流程列表
 */
@inject('fnaExpenseCommonListStore')
@observer
class FnaExpenseCommonList extends React.Component {

	static contextTypes = {
	    router: routerShape
	};

	constructor(props) {
		super(props);
	}

	componentDidMount() {
		//一些初始化请求
		const { fnaExpenseCommonListStore,location } = this.props;	
        const {initDataList} = fnaExpenseCommonListStore;	
        //console.log("location",location);
        if(JSON.stringify(location.query) != '{}'){
        	initDataList(location.query);
        }	
	}

	shouldComponentUpdate(nextProps, nextState) {
		
		return true;
	}

	componentWillUnmount() {
		//组件卸载时一般清理一些状态

	}

	getTopButton(){

	}

	getRightMenu(){

	}

	render() {
		
		const { fnaExpenseCommonListStore } = this.props;
		const {dataKey,tableStore} = fnaExpenseCommonListStore;
		return (
			<div>
				<WeaTable 
                    comsWeaTableStore={tableStore}
                    getColumns={this.getColumnsInfo.bind(this)}
                />
			</div>
		);
	}

	showallreceived(record,index){
		let requestid = record.requestid;
		let returntdid = requestid + "_" + index;
        let _data ="requestid="+requestid+"&returntdid="+returntdid;
        jQuery.ajax({
            url : "/workflow/search/WorkflowUnoperatorPersons.jsp",
            type : "post",
            processData : false,
            data : _data, 
            dataType : "text",
            success: function do4Success(msg){ 
            	jQuery("#"+returntdid).html(msg);
            }
        });
        
    }


	getColumnsInfo(data){
		const that = this;
		if(!isEmpty(data)){
			data[8].render = (text, record, index) => {
				let id = record.requestid + "_" + index;
				return (<a id={id} onClick={that.showallreceived.bind(that,record,index)}>显示</a>);
			} 
		}
		return data;
	}

	
	
}


export default WeaTools.tryCatch(React,
	props => <WeaErrorPage msg={ props.error ? props.error : '对不起，该页面异常，请联系管理员！'} />,
	{error: ""}
)(FnaExpenseCommonList);




